import { roleadd, roledelete, roleedit, roleinfo, rolelist } from "../../utils/request/api.js";
export default {
    rolelist_a( { commit }, payload) {
        rolelist(payload).then(res => {
            if (res.code == 200) {
                 commit('setrolelist',res.list)
            }
        })
    },
    roleadd_a( { commit },payload) {
        roleadd(payload).then(res => {
             commit('setroleTitle', res)
        })
    },
    roledelete_a({ commit }, payload) {
        roledelete(payload).then(res => {
            //把操作成功变成删除成功
            commit('setroleTitle', {...res,msg:"删除成功"})
        })
    },
    roleinfo_a( { commit }, payload) {
        roleinfo(payload).then(res => {
            //点击编辑的时候 直接把id添加到roleinfo上
             commit('setroleinfo',{...res.list,id:payload})
        })
    },
    roleedit_a({ commit }, payload) {
        roleedit(payload).then(res => {
            //把操作成功变成修改成功
            commit('setroleTitle',{...res,msg:"修改成功"})
        })
    },
}